PHP_ARG_ENABLE(indigo, whether to enable Indigo modules,
	[ --enable-indigo            Enable Indigo modules.],
	yes, yes)
PHP_ARG_ENABLE(dingo, whether to enable Dingo library support,
	[  --enable-dingo            Include Dingo support.],
	yes, yes)
PHP_ARG_ENABLE(cano, whether to enable Cano library support,
	[  --enable-cano             Include Cano support.],
	yes, yes)

SOURCES="indigo.cc"
LIBDIR="indigolibs"
PHP_SUBST(INDIGO_SHARED_LIBADD)

if test "$PHP_DINGO" != "no" -a "$PHP_INDIGO" != "no"; then
	dnl Library names in reverse order - in adding process this list will be reversed.
	DINGO_LIBNAMES="graph molecule reaction layout render2d dingo"
	SOURCES="$SOURCES dingo.cc"
	AC_DEFINE(HAVE_DINGO, 1, [Whether you have Dingo library])
	PHP_ADD_INCLUDE(indigo/dingo/c)
	PHP_ADD_INCLUDE(indigo/common)

	for LIBNAME in $DINGO_LIBNAMES;
	do
		if test -r $LIBDIR/lib$LIBNAME.a;
		then
			AC_MSG_RESULT(Library files $LIBNAME found in $LIBDIR)
			PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $LIBDIR, INDIGO_SHARED_LIBADD)
		else
			AC_MSG_RESULT(Library files $LIBNAME not found)
			AC_MSG_ERROR(Please, reinstall Dingo)
		fi
	done
	PHP_ADD_LIBRARY(cairo, 1, INDIGO_SHARED_LIBADD)
	PHP_ADD_LIBRARY(pthread, 1, INDIGO_SHARED_LIBADD)
fi

if test "$PHP_CANO" != "no" -a "$PHP_INDIGO" != "no"; then
	CANO_LIBNAMES="cano"
	SOURCES="$SOURCES cano.cc"
	AC_DEFINE(HAVE_CANO, 1, [Whether you have Cano library])
	PHP_ADD_INCLUDE(indigo/cano)
	PHP_ADD_INCLUDE(indigo/common)
	for LIBNAME in $CANO_LIBNAMES;
	do
		if test -r $LIBDIR/lib$LIBNAME.a;
		then
			AC_MSG_RESULT(Library files $LIBNAME found in $LIBDIR)
			PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $LIBDIR, INDIGO_SHARED_LIBADD)
		else
			AC_MSG_RESULT(Library files $LIBNAME not found)
			AC_MSG_ERROR(Please, reinstall Cano)
		fi
	done

fi

if test "$PHP_INDIGO" != "no"; then
	PHP_REQUIRE_CXX
	PHP_ADD_LIBRARY(stdc++, 1, INDIGO_SHARED_LIBADD)
	PHP_NEW_EXTENSION(Indigo, $SOURCES, $ext_shared)
fi
